/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MenuServicoPesca.java
 *
 * Created on 21/09/2009, 10:36:30
 */

package JPaneis;

import Conector.Conector;
import Conector.PDFPrintPage;
import Data.Pessoa;
import Data.Cliente;
import Data.ServicoPesca;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.draw.LineSeparator;
import com.lowagie.tools.Executable;
import com.sun.pdfview.PDFFile;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
import java.util.Date;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.SimpleDoc;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.JobName;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import siii.MenuPadrao;


public class MenuServicoPesca extends javax.swing.JPanel implements panelTools{

    private MenuPadrao menuPadrao;
    private Conector conector;
    private Cliente pescador;
    private boolean clienteEncontrado;
    private boolean vendaRealizada;
    private boolean valorCalculado;
    private float total = 0;
    private float desconto = 0;
    private float valorTotal;
    public int numero_servico_pesca;
    private ImageIcon iconeOK;
    private ImageIcon iconeERRO;
    private ImageIcon iconeATENCAO;
    String aux;

    /** Creates new form MenuServicoPesca */
    public MenuServicoPesca(MenuPadrao m, Conector con) {
        this.menuPadrao = m;
        this.conector = con;
        initComponents();
        validaValor.setVisible(false);
        clienteEncontrado = false;
        valorCalculado = false;
        vendaRealizada = false;
        iconeOK = new ImageIcon(getClass().getResource("/Images/fish-48x48ok.png"));
        iconeERRO = new ImageIcon(getClass().getResource("/Images/fish-48x48erro.png"));
        iconeATENCAO = new ImageIcon(getClass().getResource("/Images/fish-48x48atencao1.png"));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pescSobrenome = new javax.swing.JFormattedTextField();
        pescNome = new javax.swing.JFormattedTextField();
        jLabelNome = new javax.swing.JLabel();
        jLabelCPF = new javax.swing.JLabel();
        jLabelSobrenome = new javax.swing.JLabel();
        pescNumPescador = new javax.swing.JFormattedTextField();
        jLabelNumPescador = new javax.swing.JLabel();
        pescCPF = new javax.swing.JFormattedTextField();
        jButtonConsultar = new javax.swing.JButton();
        jLabelServicoPesca = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabelPeriodo = new javax.swing.JLabel();
        jButtonCancelar = new javax.swing.JButton();
        jButtonConfirmar = new javax.swing.JButton();
        pescCrianca = new javax.swing.JComboBox();
        pescTotal = new javax.swing.JLabel();
        jLabelTotal = new javax.swing.JLabel();
        pescValor = new javax.swing.JLabel();
        jLabelValor = new javax.swing.JLabel();
        jLabelDesconto = new javax.swing.JLabel();
        jLabelMasculino = new javax.swing.JLabel();
        jLabelCrianca = new javax.swing.JLabel();
        jLabelFeminino = new javax.swing.JLabel();
        pescMasculino = new javax.swing.JComboBox();
        jLabelQuantidade = new javax.swing.JLabel();
        pescFeminino = new javax.swing.JComboBox();
        jLabelTurno = new javax.swing.JLabel();
        pescTurno = new javax.swing.JComboBox();
        pescPeriodo = new javax.swing.JComboBox();
        pescDesconto = new javax.swing.JFormattedTextField();
        jButton1 = new javax.swing.JButton();
        validaValor = new javax.swing.JLabel();
        real2 = new javax.swing.JLabel();
        real = new javax.swing.JLabel();
        real1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1000, 550));

        pescSobrenome.setToolTipText("Digite o Sobrenome do Pescador");

        pescNome.setToolTipText("Digite o nome do Pescador");

        jLabelNome.setText("Nome");

        jLabelCPF.setText("C.P.F");

        jLabelSobrenome.setText("Sobrenome");

        pescNumPescador.setToolTipText("Digite o numero do pescador");

        jLabelNumPescador.setText("Número do Pescador");

        try {
            pescCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pescCPF.setToolTipText("Digite o CPF");

        jButtonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/fish-48x48buscar.png"))); // NOI18N
        jButtonConsultar.setText("Consultar");
        jButtonConsultar.setToolTipText("Com algum dos dados preenchidos o Consultar procura o Cliente e preenche os demais campos");
        jButtonConsultar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedBuscar(evt);
            }
        });

        jLabelServicoPesca.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabelServicoPesca.setText("Serviço de Pesca");
        jLabelServicoPesca.setToolTipText("Para um serviço poder ser realizado existe a necessidade de preencher algum dos campos abaixo");

        jLabelPeriodo.setText("Período");

        jButtonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_cancelar.png"))); // NOI18N
        jButtonCancelar.setText("Cancelar");
        jButtonCancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedCancelarHandler(evt);
            }
        });

        jButtonConfirmar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_add.png"))); // NOI18N
        jButtonConfirmar.setText("Confirmar / Imprimir");
        jButtonConfirmar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonConfirmarMouseClicked(evt);
            }
        });
        jButtonConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConfirmarActionPerformed(evt);
            }
        });

        pescCrianca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        pescCrianca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pescCriancaActionPerformed(evt);
            }
        });

        pescTotal.setText("0.00");

        jLabelTotal.setText("Valor Total");

        pescValor.setText("0.00");

        jLabelValor.setText("Valor");

        jLabelDesconto.setText("Desconto");

        jLabelMasculino.setText("Masculino");

        jLabelCrianca.setText("Criança");

        jLabelFeminino.setText("Feminino");

        pescMasculino.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        pescMasculino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pescMasculinoActionPerformed(evt);
            }
        });

        jLabelQuantidade.setText("Quantidade");

        pescFeminino.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        pescFeminino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pescFemininoActionPerformed(evt);
            }
        });

        jLabelTurno.setText("Turno");

        pescTurno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Diurno", "Noturno" }));
        pescTurno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pescTurnoActionPerformed(evt);
            }
        });

        pescPeriodo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Integral", "Meio-Período" }));
        pescPeriodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pescPeriodoActionPerformed(evt);
            }
        });

        try {
            pescDesconto.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##,##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pescDesconto.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        pescDesconto.setToolTipText("Digite o Desconto");
        pescDesconto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                pescDescontoFocusLost(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/calcular.png"))); // NOI18N
        jButton1.setText("Calcular");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        validaValor.setForeground(new java.awt.Color(255, 0, 0));
        validaValor.setText("Favor Calcular");

        real2.setText("R$");

        real.setText("R$");

        real1.setText("R$");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelFeminino)
                    .addComponent(jLabelMasculino)
                    .addComponent(jLabelCrianca))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pescMasculino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pescFeminino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pescCrianca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(46, 46, 46))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelQuantidade)
                        .addGap(37, 37, 37)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelTurno)
                        .addGap(66, 66, 66)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelPeriodo)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(pescPeriodo, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(validaValor))))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pescTurno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(131, 131, 131)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelValor)
                    .addComponent(jLabelTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(real)
                        .addGap(18, 18, 18)
                        .addComponent(pescValor))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(real2)
                        .addGap(18, 18, 18)
                        .addComponent(pescTotal))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(real1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pescDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(150, 150, 150))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 971, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(187, 187, 187)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelSobrenome)
                            .addComponent(jLabelNome))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(pescSobrenome, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabelCPF)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(pescCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(pescNome, javax.swing.GroupLayout.PREFERRED_SIZE, 445, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelNumPescador)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pescNumPescador, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(172, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jLabelServicoPesca, javax.swing.GroupLayout.PREFERRED_SIZE, 562, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(401, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(653, Short.MAX_VALUE)
                .addComponent(jButtonConfirmar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCancelar)
                .addGap(70, 70, 70))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jLabelServicoPesca, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelNumPescador)
                            .addComponent(pescNumPescador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelNome)
                            .addComponent(pescNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelSobrenome)
                            .addComponent(pescSobrenome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelCPF)
                            .addComponent(pescCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jButtonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(47, 47, 47)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabelQuantidade)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabelPeriodo)
                                        .addComponent(jLabelTurno)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(pescMasculino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pescTurno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pescPeriodo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(12, 12, 12))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabelMasculino)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(pescFeminino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelFeminino))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButton1)
                                    .addComponent(validaValor)))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(pescCrianca, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabelCrianca))))
                        .addGap(37, 37, 37))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelValor)
                            .addComponent(pescValor, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(real))
                        .addGap(25, 25, 25)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelDesconto)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(pescDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(real1)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelTotal)
                            .addComponent(pescTotal)
                            .addComponent(real2))
                        .addGap(54, 54, 54)))
                .addGap(95, 95, 95))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(445, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCancelar)
                    .addComponent(jButtonConfirmar))
                .addGap(64, 64, 64))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void mouseClickedCancelarHandler(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseClickedCancelarHandler
        // TODO add your handling code here:
        this.cleanScreen();
        menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
    }//GEN-LAST:event_mouseClickedCancelarHandler

    private void mouseClickedBuscar(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseClickedBuscar


        String cpf = pescCPF.getText().replace(".", "").replace("-", "").replace(" ", "");
    if (pescNumPescador.getText().length() > 0) {
        pescador = new Cliente(Integer.parseInt(pescNumPescador.getText()), pescNome.getText(), pescSobrenome.getText(), cpf);
    } else {
        pescador = new Cliente(0, pescNome.getText(), pescSobrenome.getText(), cpf);
    }
    try {

            Cliente pesc = new Cliente();
            pesc = conector.consultarClienteParaPesca(pescador, this);

            if(pesc.isFlagClienteNaoEncontrado())
                JOptionPane.showMessageDialog(this, "Cliente não encontrado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
            else {
                setClientScreen(pesc);
                clienteEncontrado = true;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            conector = new Conector();
          }
    }//GEN-LAST:event_mouseClickedBuscar

    private void jButtonConfirmarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonConfirmarMouseClicked
        Date data_atendimento = null;
        vendaRealizada = false;
        if(clienteEncontrado) {
            if(valorCalculado) {
                if(!(desconto > total) || desconto != total)
                {
                        conector.insereServicoPesca(pescTurno.getSelectedItem().toString(),
                            pescPeriodo.getSelectedItem().toString(),
                            (Integer.parseInt(pescMasculino.getSelectedItem().toString())+
                            Integer.parseInt(pescFeminino.getSelectedItem().toString()) +
                            Integer.parseInt(pescCrianca.getSelectedItem().toString())), total, Integer.parseInt(pescNumPescador.getText()));
                            aux =  JOptionPane.showInputDialog("Horário de Saída:");
                    JOptionPane.showMessageDialog(this, "Servico realizado com sucesso", "Atenção", JOptionPane.WARNING_MESSAGE, iconeOK);
                    vendaRealizada = true;
//                  List<Map<String,?>> dadosServico =  conector.doRawSql("SELECT TOP 1 * FROM SERVICOS_REALIZADOS_PESCA");

                    List<Map<String,?>> dadosServico =  conector.doRawSql("SELECT MAX(NUMERO_SERVICO) AS  NUMERO_SERVICO FROM SERVICOS_REALIZADOS_PESCA");

                    List<Map<String,?>> dadosPesqueiro =  conector.doRawSql("SELECT * FROM PESQUEIROS");

                    List<Map<String,?>> dadosPescador =  conector.doRawSql("SELECT * FROM CLIENTES WHERE NUMERO_DO_PESCADOR = " + pescNumPescador.getText());

                    String nomePescador = (String) dadosPescador.get(0).get("NOME");

                    String nomePesqueiro = (String) dadosPesqueiro.get(0).get("NOME");
                    String endereco = (String) dadosPesqueiro.get(0).get("LOGRADOURO");
                    String numero = (String) dadosPesqueiro.get(0).get("NUMERO");
                    String bairro = (String) dadosPesqueiro.get(0).get("BAIRRO");
                    String cidade = (String) dadosPesqueiro.get(0).get("CIDADE");
                    String estado = (String) dadosPesqueiro.get(0).get("ESTADO");
                    String cep = (String) dadosPesqueiro.get(0).get("CEP");
                    String tel = (String) dadosPesqueiro.get(0).get("TELEFONE");
                    String email = (String) dadosPesqueiro.get(0).get("EMAIL");
                    String site = (String) dadosPesqueiro.get(0).get("SITE");
                    Integer ordemServico = (Integer) dadosServico.get(0).get("NUMERO_SERVICO");

                        List<Map<String,?>> dadosServico1 =  conector.doRawSql("SELECT HORARIO FROM SERVICOS_REALIZADOS_PESCA WHERE NUMERO_SERVICO = " + ordemServico);

                    String dataHorario = dadosServico1.get(0).get("HORARIO").toString();


                    imprimirCupom(  Integer.parseInt(pescNumPescador.getText()), nomePesqueiro, tel, email, endereco, numero, bairro,
                                    cidade, estado, cep, nomePescador, (ordemServico + 1),
                                    dataHorario,
                                    pescTurno.getSelectedItem().toString(),
                                    pescPeriodo.getSelectedItem().toString(),
                                    (Integer.parseInt(pescMasculino.getSelectedItem().toString())+ Integer.parseInt(pescFeminino.getSelectedItem().toString())+Integer.parseInt(pescCrianca.getSelectedItem().toString())),
                                    valorTotal, site, aux);
                        
                }
                else
                    JOptionPane.showMessageDialog(this, "Desconto maior ou igual ao valor do serviço", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
            }
            else {
                validaValor.setVisible(true);
            }
        } else {

            JOptionPane.showMessageDialog(this, "Favor Buscar cliente", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
        }

        if(vendaRealizada) {
            cleanScreen();
            menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
        }
    }//GEN-LAST:event_jButtonConfirmarMouseClicked

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        // TODO add your handling code here:
        String qtdeHomem, qtdeMulher, qtdeCrianca, turno, periodo, valor;
        total = (float) 0.0;
        qtdeHomem = pescMasculino.getSelectedItem().toString();
        qtdeMulher = pescFeminino.getSelectedItem().toString();
        qtdeCrianca = pescCrianca.getSelectedItem().toString();
        turno = pescTurno.getSelectedItem().toString();
        periodo = pescPeriodo.getSelectedItem().toString();

        try {
        if(conector.consultaCadastroServicoPesca(turno, periodo)) {
        if(Integer.parseInt(qtdeHomem) != 0 || Integer.parseInt(qtdeMulher) != 0 || Integer.parseInt(qtdeCrianca) != 0) {
            if(Integer.parseInt(qtdeHomem) > 0) {
            try {
                total+= (Integer.parseInt(qtdeHomem) * (conector.consultarValorServicoPesca("Homem", turno, periodo)));
                pescValor.setText(String.valueOf(total));
                pescTotal.setText(String.valueOf(total));
//                System.out.println(total);

            } catch (SQLException ex) {
                Logger.getLogger(MenuServicoPesca.class.getName()).log(Level.SEVERE, null, ex);
                conector = new Conector();
            }
        }
        } else
                JOptionPane.showMessageDialog(this, "Favor selecionar pescadores", "Atenção", JOptionPane.WARNING_MESSAGE, iconeATENCAO);

        if(Integer.parseInt(qtdeMulher) > 0) {
            try {
                total+= (Integer.parseInt(qtdeMulher) * (conector.consultarValorServicoPesca("Mulher", turno, periodo)));
                pescValor.setText(String.valueOf(total));
                pescTotal.setText(String.valueOf(total));
            } catch (SQLException ex) {
                Logger.getLogger(MenuServicoPesca.class.getName()).log(Level.SEVERE, null, ex);
                conector = new Conector();
            }
        }

        if(Integer.parseInt(qtdeCrianca) > 0) {
            try {
                total+= (Integer.parseInt(qtdeCrianca) * (conector.consultarValorServicoPesca("Crianca", turno, periodo)));
                pescValor.setText(String.valueOf(total));
                pescTotal.setText(String.valueOf(total));

            } catch (SQLException ex) {
                Logger.getLogger(MenuServicoPesca.class.getName()).log(Level.SEVERE, null, ex);
                conector = new Conector();
            }
        }
        valorCalculado = true;
        valorTotal = total;
        pescValor.setText(String.valueOf(total));
        pescTotal.setText(String.valueOf(total));
        }
        else {

            JOptionPane.showMessageDialog(this, "Serviço não cadastrado", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
        }

        }
        catch(Exception e) {
            e.printStackTrace();
            conector = new Conector();
        }
    }//GEN-LAST:event_jButton1MouseClicked

    private void pescMasculinoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pescMasculinoActionPerformed
        // TODO add your handling code here:
        valorCalculado = false;
    }//GEN-LAST:event_pescMasculinoActionPerformed

    private void pescFemininoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pescFemininoActionPerformed
        // TODO add your handling code here:
        valorCalculado = false;
    }//GEN-LAST:event_pescFemininoActionPerformed

    private void pescCriancaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pescCriancaActionPerformed
        valorCalculado = false;
        // TODO add your handling code here:
    }//GEN-LAST:event_pescCriancaActionPerformed

    private void pescTurnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pescTurnoActionPerformed
        valorCalculado = false;
        // TODO add your handling code here:
    }//GEN-LAST:event_pescTurnoActionPerformed

    private void pescPeriodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pescPeriodoActionPerformed
        valorCalculado = false;
        // TODO add your handling code here:
    }//GEN-LAST:event_pescPeriodoActionPerformed

    private void pescDescontoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_pescDescontoFocusLost
        // TODO add your handling code here:
        pescTotal.setText(String.valueOf(Float.parseFloat(pescValor.getText()) - Float.parseFloat(pescDesconto.getText().replace(",", "."))));
        valorTotal = Float.parseFloat(pescValor.getText()) - Float.parseFloat(pescDesconto.getText().replace(",", "."));
    }//GEN-LAST:event_pescDescontoFocusLost

    private void jButtonConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfirmarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonConfirmarActionPerformed
private void setClientScreen() {
        setClientScreen(pescador);
    }

    public void setClientScreen(Cliente setCli) {
        pescNumPescador.setText(String.valueOf(setCli.getNumeroPescador()));
        pescNome.setText(setCli.getNome());
        pescSobrenome.setText(setCli.getSobrenome());
        pescCPF.setText(setCli.getCpf());
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JButton jButtonConfirmar;
    private javax.swing.JButton jButtonConsultar;
    private javax.swing.JLabel jLabelCPF;
    private javax.swing.JLabel jLabelCrianca;
    private javax.swing.JLabel jLabelDesconto;
    private javax.swing.JLabel jLabelFeminino;
    private javax.swing.JLabel jLabelMasculino;
    private javax.swing.JLabel jLabelNome;
    private javax.swing.JLabel jLabelNumPescador;
    private javax.swing.JLabel jLabelPeriodo;
    private javax.swing.JLabel jLabelQuantidade;
    private javax.swing.JLabel jLabelServicoPesca;
    private javax.swing.JLabel jLabelSobrenome;
    private javax.swing.JLabel jLabelTotal;
    private javax.swing.JLabel jLabelTurno;
    private javax.swing.JLabel jLabelValor;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JFormattedTextField pescCPF;
    private javax.swing.JComboBox pescCrianca;
    private javax.swing.JFormattedTextField pescDesconto;
    private javax.swing.JComboBox pescFeminino;
    private javax.swing.JComboBox pescMasculino;
    private javax.swing.JFormattedTextField pescNome;
    private javax.swing.JFormattedTextField pescNumPescador;
    private javax.swing.JComboBox pescPeriodo;
    private javax.swing.JFormattedTextField pescSobrenome;
    private javax.swing.JLabel pescTotal;
    private javax.swing.JComboBox pescTurno;
    private javax.swing.JLabel pescValor;
    private javax.swing.JLabel real;
    private javax.swing.JLabel real1;
    private javax.swing.JLabel real2;
    private javax.swing.JLabel validaValor;
    // End of variables declaration//GEN-END:variables

    public void setScreen(Pessoa pessoa){
        this.clienteEncontrado = pessoa != null;
        setClientScreen((Cliente) pessoa);
    }

    private void cleanScreen() {
        validaValor.setVisible(false);
        pescNumPescador.setText("");
        pescNome.setText("");
        pescSobrenome.setText("");
        pescCPF.setText("");
        pescMasculino.setSelectedItem("0");
        pescFeminino.setSelectedItem("0");
        pescCrianca.setSelectedItem("0");
        pescTurno.setSelectedItem("Diurno");
        pescPeriodo.setSelectedItem("Integral");
        pescValor.setText("0.00");
        pescDesconto.setText("");
        pescTotal.setText("0.00");
        clienteEncontrado = false;
        vendaRealizada = false;
        valorCalculado = false;
        total = 0;
        desconto = 0;
    }


    public static void imprimir(byte[] dados) {


        try {

            //DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
            DocFlavor docFlavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            System.out.println("preparando para imprimir: " + dados.length);
 
            InputStream prin = new ByteArrayInputStream(dados);
            SimpleDoc documentoTexto = new SimpleDoc(dados, docFlavor, null);

            

            PrintRequestAttributeSet printerAttributes = new HashPrintRequestAttributeSet();
            printerAttributes.add(new JobName("Impressao-Vai que vai", null));
            printerAttributes.add(OrientationRequested.PORTRAIT);
            printerAttributes.add(MediaSizeName.ISO_A4); // informa o tipo de folha

            PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
            PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
            PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
            PrintService impressora = ServiceUI.printDialog(
               null, 100, 100, services, svc, null, attrs);

            System.out.println(Arrays.asList(impressora.getSupportedDocFlavors()));
            //PrintService impressora = PrintServiceLookup.lookupDefaultPrintService(); // pega a //impressora padrao
            DocPrintJob printJob = impressora.createPrintJob();

            try {
                printJob.print(documentoTexto, null); //tenta imprimir
            } catch (PrintException e) {
                JOptionPane.showMessageDialog(null, "Não foi possível realizar a impressão !!", "Erro", JOptionPane.ERROR_MESSAGE); // mostra //mensagem de erro
                e.printStackTrace();
            }
            
            prin.close();


        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("IMPRIMIU!!");

    }

    public static void abreNoPdf(File path) {
        try {
            Desktop.getDesktop().open(path);
        } catch (IOException exc) {/*handle exception*/
            exc.printStackTrace();
        }
    }

    public static void imprimirCupom(int numeroPescador,
            String nomePesqueiro, String telefone, String mail, String endereco, String numero, String bairro,
            String cidade, String estado, String cep, String nomePescador,int ordemServico,
            String dataHorario, String turno, String periodo, int qtde, float valor, String site, String aux){

        Document document=new Document();
                    try {

                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                       // File pdfFile = new File("comprovante_servico_piscina.pdf");

                       // PdfWriter pdfw = PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
                        PdfWriter pdfw = PdfWriter.getInstance(document, baos);

                        document.open();


              		PdfPTable table = new PdfPTable(new float[] {50f,10f,30f,30f,10f,40f});
			table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        // linha 1
			PdfPCell pesqueiro = new PdfPCell(new Paragraph(nomePesqueiro, new Font(Font.HELVETICA, 30, Font.BOLD)));
                        pesqueiro.setColspan(5);
                        pesqueiro.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(pesqueiro);
                        PdfPCell cel = new PdfPCell(new Paragraph(telefone));
			cel.setColspan(1);
                        cel.setBorder(PdfPCell.NO_BORDER);
                        cel.setVerticalAlignment(PdfPCell.ALIGN_BOTTOM);
                        table.addCell(cel);
                        PdfPCell site1 = new PdfPCell(new Paragraph(site));
			site1.setColspan(3);
                        site1.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(site1);
                        PdfPCell email = new PdfPCell(new Paragraph(mail));
			email.setColspan(3);
                        email.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(email);

                        // linha 2
                        PdfPCell rua = new PdfPCell(new Paragraph(endereco));
                        rua.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(rua);
			table.addCell(numero);
			table.addCell(bairro);
                        table.addCell(cidade);
			table.addCell(estado);
			table.addCell(cep);

			document.add(table);

                        Paragraph pula_linha = new Paragraph(new Phrase(Chunk.NEWLINE));
                        document.add(pula_linha);

                        Paragraph separator = new Paragraph(0);
                        separator.add(new Chunk(new LineSeparator(1, 80, Color.BLACK, Element.ALIGN_CENTER, -2)));

                        document.add(separator);

                        PdfPTable table2 = new PdfPTable(new float[] {20f,72f,25f,20f});
                        table2.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        table2.addCell("Pescador:");
                        table2.addCell(nomePescador);
                        table2.addCell("Nº Pescador:");

                        table2.addCell(Integer.toString(numeroPescador));

                        document.add(table2);

                        document.add(separator);

                        PdfPTable table3 = new PdfPTable(new float[] {90f, 40f, 20f});
                        table3.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        table3.addCell("Serviço de Pesca");
                        table3.addCell("Ordem de Serviço: ");
                        table3.addCell(Integer.toString(ordemServico));


                        document.add(table3);

                        PdfPTable table4 = new PdfPTable(new float[] {80f,30f,50f,20f,40f});
                        table4.addCell("Data e Horário");
                        table4.addCell("Turno");
                        table4.addCell("Periodo");
                        table4.addCell("Qtd");
                        table4.addCell("Valor (R$)");

                        document.add(table4);

                        PdfPTable table5 = new PdfPTable(new float[] {80f,30f,50f,20f,40f});
                        table5.addCell(dataHorario);
                        table5.addCell(turno);
                        table5.addCell(periodo);
                        table5.addCell(Integer.toString(qtde));
                        table5.addCell(Float.toString(valor));

                        document.add(table5);

                        PdfPTable table6 = new PdfPTable(new float[] {100f,100f});
                        table6.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        PdfPCell aquicultura = new PdfPCell(new Paragraph(("Aquicultura Peressinotti"), new Font(Font.HELVETICA, 10, Font.BOLD)));
                        aquicultura.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura);
                        PdfPCell pesqueiroMarco = new PdfPCell(new Paragraph(("Pesqueiro do Marco"), new Font(Font.HELVETICA, 10, Font.BOLD)));
                        pesqueiroMarco.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco);
                        PdfPCell aquicultura1 = new PdfPCell(new Paragraph(("Vendas de peixe adulto e entraga para pesqueiros"), new Font(Font.HELVETICA, 8)));
                        aquicultura1.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura1);
                        PdfPCell pesqueiroMarco1 = new PdfPCell(new Paragraph(("Horário de Funcionamento:"), new Font(Font.HELVETICA, 8)));
                        pesqueiroMarco1.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco1);
                        PdfPCell aquicultura2 = new PdfPCell(new Paragraph(("Fone: (19)3844-5337/3833-2987"), new Font(Font.HELVETICA, 8)));
                        aquicultura2.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura2);
                        PdfPCell pesqueiroMarco2 = new PdfPCell(new Paragraph(("De 2ª à Sábado das 7h00m as 22h00m"), new Font(Font.HELVETICA, 8)));
                        pesqueiroMarco2.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco2);
                        PdfPCell aquicultura3 = new PdfPCell(new Paragraph(("          (19)9222-4969/7808-1765/ID 89*25040"), new Font(Font.HELVETICA, 8)));
                        aquicultura3.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura3);
                        PdfPCell pesqueiroMarco3 = new PdfPCell(new Paragraph(("Aos Domingos das 7h00m as 18h00m"), new Font(Font.HELVETICA, 8)));
                        pesqueiroMarco3.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco3);
                        PdfPCell aquicultura4 = new PdfPCell(new Paragraph(("Marco A. Peressinotti"), new Font(Font.HELVETICA, 8)));
                        aquicultura4.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura4);
                        PdfPCell pesqueiroMarco4 = new PdfPCell(new Paragraph(("Pesca Noturna: Quinta, Sexta, Sábado e Véspera de Feriado"), new Font(Font.HELVETICA, 7)));
                        pesqueiroMarco4.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco4);
                        PdfPCell aquicultura5 = new PdfPCell(new Paragraph(("                                  "), new Font(Font.HELVETICA, 7)));
                        aquicultura5.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(aquicultura5);
                        PdfPCell pesqueiroMarco5 = new PdfPCell(new Paragraph(("Limite: 4 Molinetes e 2 Varas de Mão por Pescador."), new Font(Font.HELVETICA, 8)));
                        pesqueiroMarco5.setBorder(PdfPCell.NO_BORDER);
                        table6.addCell(pesqueiroMarco5);

                        document.add(table6);

                        document.add(separator);

                        PdfPTable aviso = new PdfPTable(new float[] {200f});
                        aviso.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        PdfPCell avisoPescaGratis = new PdfPCell(new Paragraph(("Junte 10 comprovantes de pesca inteira ou 20 comprovantes de meia pesca e ganhe uma PESCA GRÁTIS"), new Font(Font.TIMES_ROMAN, 9)));
                        avisoPescaGratis.setBorder(PdfPCell.NO_BORDER);
                        aviso.addCell(avisoPescaGratis);

                        document.add(aviso);


                        PdfPTable susi = new PdfPTable(new float[] {200f});
                        susi.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        PdfPCell info = new PdfPCell(new Paragraph(("Informações: SUSI  -     Cel.: (19)9611-1139/(19)93635733"), new Font(Font.HELVETICA, 12)));
                        info.setBorder(PdfPCell.NO_BORDER);
                        susi.addCell(info);
                        PdfPCell info1 = new PdfPCell(new Paragraph(("                                     Nextel: (19)7808-1763/ID 89*25039"), new Font(Font.HELVETICA, 12)));
                        info1.setBorder(PdfPCell.NO_BORDER);
                        susi.addCell(info1);

                        document.add(susi);

                        document.add(pula_linha);

                        PdfPTable biblia = new PdfPTable(new float[] {200f});
                        biblia.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        PdfPCell versiculo = new PdfPCell(new Paragraph(("                                                                       Guarda-me, ó Deus, porque em ti me refugio. (Salmo 16.1)"), new Font(Font.ITALIC, 7, Font.ITALIC)));
                        versiculo.setBorder(PdfPCell.NO_BORDER);
                        biblia.addCell(versiculo);

                        PdfPTable tableHorario = new PdfPTable(new float[] {100f,100f,100f,100f});
                        tableHorario.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                        PdfPCell horario_saida = new PdfPCell(new Paragraph(("Horário de saída:"), new Font(Font.HELVETICA, 12, Font.BOLD)));
                        horario_saida.setBorder(PdfPCell.NO_BORDER);
                        tableHorario.addCell(" ");
                        tableHorario.addCell(horario_saida);
                        tableHorario.addCell(aux);
                        tableHorario.addCell(" ");
                                               
                        document.add(tableHorario);

                        document.add(pula_linha);

                        document.add(biblia);                     

                        Paragraph separator_final = new Paragraph(0);
                        separator_final.add(new Chunk(new LineSeparator(1, 80, Color.LIGHT_GRAY, Element.ALIGN_CENTER, -2)));

                        document.add(separator_final);

                        document.close();
                        pdfw.close();

                        ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
                        PDFFile sunPdfFile; // Create PDF Print Page
            try {
                sunPdfFile = new PDFFile(bb);
                PDFPrintPage pages = new PDFPrintPage(sunPdfFile);

                PrinterJob pjob = PrinterJob.getPrinterJob();
                //PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
                pjob.setPrintable(pages);
                pjob.setJobName("Comprovante de serviço");
                if(pjob.printDialog()){
                        pjob.print();
                }

            } catch (IOException ex) {
            Logger.getLogger(MenuComprarPeixePiscina.class.getName()).log(Level.SEVERE, null, ex);
                  } catch (PrinterException ex) {
                Logger.getLogger(MenuComprarPeixePiscina.class.getName()).log(Level.SEVERE, null, ex);
            }

            try {
                baos.close();
                //abreNoPdf(pdfFile);
            } catch (IOException ex) {
                Logger.getLogger(MenuServicoPesca.class.getName()).log(Level.SEVERE, null, ex);
            }

          } catch (DocumentException ex) {
              Logger.getLogger(MenuCadastrarCompraPeixes.class.getName()).log(Level.SEVERE, null, ex);
          }
    }

    public void setScreen2(ServicoPesca servPesca) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
